
var 免费领花币="240541527439405056";
var 免费领会员="327742176840740864";
var 领听书会员="370895370772901888";




launchPackage ("com.android.mediacenter");
sleep(1000);
    if(text("同意").findOne(10000)){
        click("同意")
   }
领会员();
听书会员();
领花币();
function 领会员(){
   
    sleep(1000);
   
    打开抽奖页面(免费领会员)
    sleep(3000);
    if(textContains("次抽奖机会").findOne(3000)){
        sleep(5000);
         click(500,1380)
        sleep(2000)
        click("去登录")
    }
    textContains("每天限10次").findOne ();
    sleep(5000);
    click(365,1475);
    while(1){
        click("取消");
        if(textContains("还有0次抽中大奖的机会").exists()){
            sleep(3000);
            break;
        }
    click(500,1300);
    sleep(1000);
    click(500,1850);
    }
   
}

function 听书会员(){

  sleep(1000);
  打开抽奖页面(领听书会员)
  sleep(3000);
  if(textContains("次抽奖机会").findOne(3000)){
      sleep(5000);
       click(500,1350)
      sleep(2000)
      click("去登录")
  }
    textContains("每天限10次").findOne ();
    sleep(5000);
    while(1){
        if(textContains("还有0次抽中大奖的机会").exists()){
            sleep(3000);
            break;
        }
    click(535,1452);
    sleep(1000);
    click(530,1826);
    }
   
}

function 领花币(){
  
    sleep(1000);
    打开抽奖页面(免费领花币)
    sleep(3000);
    if(textContains("次抽奖机会").findOne(3000)){
        sleep(5000);
         click(500,1350)
        sleep(2000)
        click("去登录")
    }
    textContains("每天限10次").findOne ();
    sleep(5000);
    while(1){
        if(textContains("还有0次抽中大奖的机会").exists()){
            sleep(3000);
            break;
        }
    click(542,1373);
    sleep(1000);
    click(543,1888);
    }
    
}

function 打开抽奖页面(活动名){
    console.log(活动名);
        app.startActivity({        
              action: "android.intent.action.VIEW",
                     data: "hwmediacenter://com.android.mediacenter/showH5?pver=121000000&portal=hwmusic&from=com.huawei.musicplatform.campaignh5&needback=0&channelid=1&url=https://campaign-music.hicloud.com/camp/"+活动名+"/index.html#/home?operator=8&needback=true&shared=true",
                           packageName: "com.android.mediacenter"
                     });
    }
function 关闭音乐() {
    
   // openAppSetting("com.android.mediacenter");
    while (!click("强行停止"));
    sleep (1000);
    while (!click("强行停止"));
    home();
    sleep (3000);
}


try{
//华为音乐签到
app.startActivity({
    action: "android.intent.action.VIEW",
  packageName:"com.android.mediacenter",
  data: 'hwmediacenter://com.android.mediacenter/showH5?pver=121000000&portal=hwmusic&from=com.huawei.musicplatform.campaignh5&needback=0&channelid=1&url=https%3A%2F%2Fcampaign-music.hicloud.com%2Fcamp%2F248404751211917312%2Findex.html%3Fappsafearguments%3Dtrue%26activity%3Dtrue%26operator%3D8%26share%3Dtrue%26transparentstatusbar%3Dtrue%26hideactionbar%3Dtrue%26needback%3Dtrue'
   });
sleep (15000)
}catch(err){
    log(err)
    }
  


try{
//华为视频签到
app.startActivity({
  action: "android.intent.action.VIEW",
packageName:"com.huawei.himovie",
data: 'himovie://com.huawei.himovie/showcampaign?campaignid=himovie.fuliditu7'
 });
sleep (15000)
}catch(err){
    log(err)
    }
 
try{
 //收音机签到
app.startActivity({        
        action: "android.intent.action.VIEW",
               data: "hwfmradio://com.huawei.android.FMRadio/showH5?pver=121000000&portal=hwmusic&from=com.huawei.musicplatform.campaignh5&needback=0&channelid=1&url=https://campaign-music.hicloud.com/i_1622512710_d/camp/235840624979439616/index.html?appsafearguments=true&nolandscapte=true&activity=true&operator=f1&transparentstatusbar=true&hideactionbar=true&share=true&needback=true&originbrand=1",
                     packageName: "com.huawei.android.FMRadio"
               });
}catch(err){
    log(err)
    }